Move BackGraphicURL property & friends to BackGraphic + fixes

This moves BackGraphicURL, HeaderGraphicURL, FooterGraphicURL and
ParaBackGraphicURL properties to BackGraphic, HeaderBackGraphic,
FooterBackGraphic and ParaBackGraphic. With this the property type
changes from String to XGraphic.

This change also fixes a bunch of test failures, changes the tests
to use the new properties and the correct type, changes the import
and export filters like xmloff and oox, to make the tests happy.

Change-Id: Ie66097514203c6dc36ab27420faf265322e9279e
Reviewed-on: https://gerrit.libreoffice.org/50760
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h
index d7d0a53..2f13be4 100644
--- a/include/editeng/memberids.h
+++ b/include/editeng/memberids.h
@@ -157,16 +157,15 @@
//BrushItem
#define MID_BACK_COLOR          0
#define MID_GRAPHIC_POSITION    1
#define MID_GRAPHIC_LINK        2
#define MID_GRAPHIC             3
#define MID_GRAPHIC_TRANSPARENT 4
#define MID_GRAPHIC_URL         5
#define MID_GRAPHIC_FILTER      6
#define MID_GRAPHIC_REPEAT      7
#define MID_GRAPHIC_TRANSPARENCY 8
#define MID_BACK_COLOR_R_G_B    9
#define MID_BACK_COLOR_TRANSPARENCY 10
#define MID_SHADING_VALUE       11
#define MID_GRAPHIC             2
#define MID_GRAPHIC_TRANSPARENT 3
#define MID_GRAPHIC_URL         4
#define MID_GRAPHIC_FILTER      5
#define MID_GRAPHIC_REPEAT      6
#define MID_GRAPHIC_TRANSPARENCY 7
#define MID_BACK_COLOR_R_G_B    8
#define MID_BACK_COLOR_TRANSPARENCY 9
#define MID_SHADING_VALUE       10

//SvxFormatBreakItem
#define MID_BREAK_BEFORE        0
diff --git a/include/oox/helper/modelobjecthelper.hxx b/include/oox/helper/modelobjecthelper.hxx
index 67980b5..694bdf1 100644
--- a/include/oox/helper/modelobjecthelper.hxx
+++ b/include/oox/helper/modelobjecthelper.hxx
@@ -27,7 +27,8 @@
#include <sal/types.h>

namespace com { namespace sun { namespace star {
    namespace awt { struct Gradient; }
    namespace awt { struct Gradient;
                    class XBitmap; }
    namespace graphic { class XGraphic; }
    namespace container { class XNameContainer; }
    namespace drawing { struct LineDash; }
@@ -113,6 +114,7 @@
    OUString insertFillBitmapXGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);

    OUString     getFillBitmapUrl( const OUString& rGraphicName );
    css::uno::Reference<css::awt::XBitmap> getFillBitmap(OUString const & rGraphicName);

private:
    ObjectContainer     maMarkerContainer;      ///< Contains all named line markers (line end polygons).
diff --git a/include/xmloff/xmltypes.hxx b/include/xmloff/xmltypes.hxx
index 8b7fc23..dc2e655 100644
--- a/include/xmloff/xmltypes.hxx
+++ b/include/xmloff/xmltypes.hxx
@@ -290,6 +290,7 @@
#define XML_SW_TYPE_BITMAPREPOFFSETY    (XML_TEXT_TYPES_START + 125)

#define XML_TYPE_TEXT_RUBY_IS_ABOVE     (XML_TEXT_TYPES_START + 126)
#define XML_TYPE_GRAPHIC                (XML_TEXT_TYPES_START + 127)

#endif // INCLUDED_XMLOFF_XMLTYPES_HXX

diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 7f6a704..c22654e 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -604,17 +604,14 @@
                    uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
                    // TODO: "rotate with shape" is not possible with our current core

                    OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
                    // push bitmap or named bitmap to property map

                    if (!aGraphicUrl.isEmpty())
                    if (xGraphic.is())
                    {
                        if (rPropMap.supportsProperty(ShapeProperty::FillBitmapNameFromUrl) &&
                            rPropMap.setProperty(ShapeProperty::FillBitmapNameFromUrl, xGraphic))
                        {
                            eFillStyle = FillStyle_BITMAP;
                        }
                        else if (rPropMap.setProperty(ShapeProperty::FillBitmapUrl, aGraphicUrl))
                        else if (rPropMap.setProperty(ShapeProperty::FillBitmapUrl, xGraphic))
                        {
                            eFillStyle = FillStyle_BITMAP;
                        }
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 6d83c68..b3c48b0 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -54,6 +54,7 @@
#include <tools/mapunit.hxx>
#include <editeng/unoprnms.hxx>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
@@ -841,16 +842,19 @@
                    aShapeProps.setAnyProperty(PROP_BackColorTransparency, aShapeProps.getProperty(PROP_FillTransparence));
                    aShapeProps.erase(PROP_FillTransparence);
                }
                // TextFrames have BackGrahicURL, not FillBitmapURL
                if (aShapeProps.hasProperty(PROP_FillBitmapURL))
                // TextFrames have BackGrahic, not FillBitmap
                if (aShapeProps.hasProperty(PROP_FillBitmap))
                {
                    aShapeProps.setAnyProperty(PROP_BackGraphicURL, aShapeProps.getProperty(PROP_FillBitmapURL));
                    aShapeProps.erase(PROP_FillBitmapURL);
                    aShapeProps.setAnyProperty(PROP_BackGraphic, aShapeProps.getProperty(PROP_FillBitmap));
                    aShapeProps.erase(PROP_FillBitmap);
                }
                if (aShapeProps.hasProperty(PROP_FillBitmapName))
                {
                    uno::Any aAny = aShapeProps.getProperty(PROP_FillBitmapName);
                    aShapeProps.setProperty(PROP_BackGraphicURL, rFilterBase.getModelObjectHelper().getFillBitmapUrl( aAny.get<OUString>() ));
                    OUString aFillBitmapName = aAny.get<OUString>();
                    uno::Reference<awt::XBitmap> xBitmap = rFilterBase.getModelObjectHelper().getFillBitmap(aFillBitmapName);
                    uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
                    aShapeProps.setProperty(PROP_BackGraphic, xGraphic);
                    // aShapeProps.erase(PROP_FillBitmapName);  // Maybe, leave the name as well
                }
                // And no LineColor property; individual borders can have colors
diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx
index 5322643..c070438 100644
--- a/oox/source/drawingml/shapepropertymap.cxx
+++ b/oox/source/drawingml/shapepropertymap.cxx
@@ -180,17 +180,20 @@
    return false;
}

bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue )
bool ShapePropertyMap::setFillBitmapUrl(sal_Int32 nPropId, const Any& rValue)
{
    // push bitmap URL explicitly
    if( !maShapePropInfo.mbNamedFillBitmapUrl )
        return setAnyProperty( nPropId, rValue );
    // push bitmap explicitly
    if (!maShapePropInfo.mbNamedFillBitmapUrl)
    {
        return setAnyProperty(nPropId, rValue);
    }

    // create named bitmap URL and push its name
    if( rValue.has< OUString >() )
    if (rValue.has<uno::Reference<graphic::XGraphic>>())
    {
        OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapUrl( rValue.get< OUString >() );
        return !aBitmapUrlName.isEmpty() && setProperty( nPropId, aBitmapUrlName );
        auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>();
        OUString aBitmapName = mrModelObjHelper.insertFillBitmapXGraphic(xGraphic);
        return !aBitmapName.isEmpty() && setProperty(nPropId, aBitmapName);
    }

    return false;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 093ed3c..469420e 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1227,7 +1227,22 @@
            uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
            if (xBitmap.is() && xGraphic.is())
            {
                WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, true);
                bool bWriteMode = false;
                if (sURLPropName == "FillBitmap" || sURLPropName == "BackGraphic")
                    bWriteMode = true;
                WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode);
            }
        }
        else if (mAny.has<uno::Reference<graphic::XGraphic>>())
        {
            uno::Reference<graphic::XGraphic> xGraphic;
            xGraphic = mAny.get<uno::Reference<graphic::XGraphic>>();
            if (xGraphic.is())
            {
                bool bWriteMode = false;
                if (sURLPropName == "FillBitmap" || sURLPropName == "BackGraphic")
                    bWriteMode = true;
                WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode);
            }
        }
        else
diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx
index 24f6e7f..95c466f 100644
--- a/oox/source/helper/modelobjecthelper.cxx
+++ b/oox/source/helper/modelobjecthelper.cxx
@@ -152,6 +152,15 @@
    return OUString();
}

uno::Reference<awt::XBitmap> ModelObjectHelper::getFillBitmap(OUString const & rGraphicName)
{
    uno::Reference<awt::XBitmap> xBitmap;
    uno::Any aAny = maBitmapUrlContainer.getObject(rGraphicName);
    if (aAny.has<uno::Reference<awt::XBitmap>>())
        xBitmap = aAny.get<uno::Reference<awt::XBitmap>>();
    return xBitmap;
}

} // namespace oox

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index b4da0cb..6754ee5 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -21,6 +21,7 @@
BackColor
BackColorTransparency
BackGraphicLocation
BackGraphic
BackGraphicURL
Background
BackgroundColor
@@ -167,6 +168,7 @@
FillBitmapSizeX
FillBitmapSizeY
FillBitmapURL
FillBitmap
FillColor
FillGradient
FillGradientName
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 3d93aac..4483158 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -3285,6 +3285,7 @@
        {
            OUString sURL;
            XPropSet->getPropertyValue("GraphicURL") >>= sURL;
            CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), !sURL.isEmpty());
            CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL != "vnd.sun.star.GraphicObject:00000000000000000000000000000000");
        }
        // Check size
@@ -3303,6 +3304,7 @@
        {
            OUString sURL;
            XPropSet->getPropertyValue("GraphicURL") >>= sURL;
            CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), !sURL.isEmpty());
            CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL != "vnd.sun.star.GraphicObject:00000000000000000000000000000000");
        }
        // Check size
@@ -3781,9 +3783,10 @@
    uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
    uno::Reference<container::XNameAccess> xPageStyles(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY);
    uno::Reference<beans::XPropertySet> xStyle(xPageStyles->getByName("Default"), uno::UNO_QUERY);
    OUString aURL;
    xStyle->getPropertyValue("HeaderBackGraphicURL") >>= aURL;
    CPPUNIT_ASSERT(aURL.startsWith("vnd.sun.star.GraphicObject:"));

    uno::Reference<graphic::XGraphic> xGraphic;
    xStyle->getPropertyValue("HeaderBackGraphic") >>= xGraphic;
    CPPUNIT_ASSERT(xGraphic.is());
    xDocSh->DoClose();
}

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index d796e58..a4b4bfe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -603,17 +603,20 @@
    uno::Sequence<beans::PropertyValue> aProps;
    xLevels->getByIndex(0) >>= aProps; // 1st level

    bool bIsGraphic = false;
    uno::Reference<graphic::XGraphic> xGraphic;
    sal_Int16 nNumberingType = -1;

    for (int i = 0; i < aProps.getLength(); ++i)
    {
        const beans::PropertyValue& rProp = aProps[i];

        if (rProp.Name == "NumberingType")
            CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>());
        else if (rProp.Name == "GraphicURL")
            bIsGraphic = true;
            nNumberingType = rProp.Value.get<sal_Int16>();
        else if (rProp.Name == "Graphic")
            xGraphic = rProp.Value.get<uno::Reference<graphic::XGraphic>>();
    }
    CPPUNIT_ASSERT_EQUAL(true, bIsGraphic);
    CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
    CPPUNIT_ASSERT(xGraphic.is());
}

DECLARE_OOXMLEXPORT_TEST(testFdo64826, "fdo64826.docx")
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index cd0b7d9..5f1b96b 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -552,17 +552,20 @@
    uno::Sequence<beans::PropertyValue> aProps;
    xLevels->getByIndex(0) >>= aProps; // 1st level

    bool bIsGraphic = false;
    uno::Reference<graphic::XGraphic> xGraphic;
    sal_Int16 nNumberingType = -1;

    for (int i = 0; i < aProps.getLength(); ++i)
    {
        const beans::PropertyValue& rProp = aProps[i];

        if (rProp.Name == "NumberingType")
            CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>());
        else if (rProp.Name == "GraphicURL")
            bIsGraphic = true;
            nNumberingType = rProp.Value.get<sal_Int16>();
        else if (rProp.Name == "Graphic")
            xGraphic = rProp.Value.get<uno::Reference<graphic::XGraphic>>();
    }
    CPPUNIT_ASSERT_EQUAL(true, bIsGraphic);
    CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
    CPPUNIT_ASSERT(xGraphic.is());
}

DECLARE_RTFEXPORT_TEST(testBookmark, "bookmark.rtf")
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 4c4c206..cafbbcd 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1432,30 +1432,27 @@
                aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_BULLET_FONT, aDesc));
            }
        }
        if(SVX_NUM_BITMAP == rFormat.GetNumberingType())
        if (SVX_NUM_BITMAP == rFormat.GetNumberingType())
        {
            //GraphicURL
            const SvxBrushItem* pBrush = rFormat.GetBrush();
            if(pBrush)
            uno::Reference<graphic::XGraphic> xGraphic;
            if (pBrush)
            {
                Any aAny;
                pBrush->QueryValue( aAny, MID_GRAPHIC_URL );
                aAny >>= aUString;
                xGraphic = pBrush->GetGraphic()->GetXGraphic();
                aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC, xGraphic));
            }
            else
                aUString.clear();
            aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_URL, aUString));

            //graphicbitmap
            //GraphicBitmap
            const Graphic* pGraphic = nullptr;
            if(pBrush )
            if (pBrush)
                pGraphic = pBrush->GetGraphic();
            if(pGraphic)
            if (pGraphic)
            {
                uno::Reference<awt::XBitmap> xBitmap(pGraphic->GetXGraphic(), uno::UNO_QUERY);
                aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_BITMAP, xBitmap));
            }
             Size aSize = rFormat.GetGraphicSize();
            Size aSize = rFormat.GetGraphicSize();
            // #i101131#
            // adjust conversion due to type mismatch between <Size> and <awt::Size>
            awt::Size aAwtSize(convertTwipToMm100(aSize.Width()), convertTwipToMm100(aSize.Height()));
@@ -1580,7 +1577,7 @@
        UNO_NAME_BULLET_FONT,                   // 17
        UNO_NAME_BULLET_FONT_NAME,              // 18
        UNO_NAME_BULLET_CHAR,                   // 19
        UNO_NAME_GRAPHIC_URL,                   // 20
        UNO_NAME_GRAPHIC,                       // 20
        UNO_NAME_GRAPHIC_BITMAP,                // 21
        UNO_NAME_GRAPHIC_SIZE,                  // 22
        UNO_NAME_VERT_ORIENT,                   // 23
@@ -1925,22 +1922,27 @@
                    }
                }
                break;
                case 20: //UNO_NAME_GRAPHIC_URL,
                case 20: //UNO_NAME_GRAPHIC,
                {
                    assert( !pDocShell );
                    OUString sBrushURL;
                    pProp->Value >>= sBrushURL;
                    if(!pSetBrush)
                    uno::Reference<graphic::XGraphic> xGraphic;
                    if (pProp->Value >>= xGraphic)
                    {
                        const SvxBrushItem* pOrigBrush = aFormat.GetBrush();
                        if(pOrigBrush)
                        if (!pSetBrush)
                        {
                            pSetBrush = new SvxBrushItem(*pOrigBrush);
                            const SvxBrushItem* pOrigBrush = aFormat.GetBrush();
                            if(pOrigBrush)
                            {
                                pSetBrush = new SvxBrushItem(*pOrigBrush);
                            }
                            else
                                pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND);
                        }
                        else
                            pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND);
                        Graphic aGraphic(xGraphic);
                        pSetBrush->SetGraphic(aGraphic);
                    }
                    pSetBrush->PutValue( pProp->Value, MID_GRAPHIC_URL );
                    else
                        bWrongArg = true;
                }
                break;
                case 21: //UNO_NAME_GRAPHIC_BITMAP,
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index ea14bc8..1f5b181 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1838,7 +1838,6 @@
        MID_BACK_COLOR,
        MID_GRAPHIC_TRANSPARENT,
        MID_GRAPHIC_POSITION,
        MID_GRAPHIC_URL,
        MID_GRAPHIC,
        MID_GRAPHIC_FILTER });

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 0e81dae..29d5cf1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -8454,7 +8454,7 @@
                    uno::Reference< drawing::XShape > xShape( const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY );
                    uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY );
                    m_rDrawingML.SetFS(m_pSerializer);
                    m_rDrawingML.WriteBlipFill( xPropertySet, "BackGraphicURL" );
                    m_rDrawingML.WriteBlipFill(xPropertySet, "BackGraphic");
                }
            }
        }
diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx
index 6bb9970..85d6bd9 100644
--- a/sw/source/filter/xml/xmlbrsh.cxx
+++ b/sw/source/filter/xml/xmlbrsh.cxx
@@ -83,9 +83,7 @@
        switch( aTokenMap.Get( nPrefix, aLocalName ) )
        {
        case XML_TOK_BGIMG_HREF:
            SvXMLImportItemMapper::PutXMLValue(
                *pItem, GetImport().ResolveGraphicObjectURL( rValue, false),
                MID_GRAPHIC_LINK, rUnitConv );
            m_xGraphic = GetImport().loadGraphicByURL(rValue);
            break;
        case XML_TOK_BGIMG_TYPE:
        case XML_TOK_BGIMG_ACTUATE:
@@ -113,24 +111,16 @@
        const uno::Reference< xml::sax::XAttributeList > & xAttrList )
{
    SvXMLImportContext *pContext = nullptr;
    if( xmloff::token::IsXMLToken( rLocalName,
                                        xmloff::token::XML_BINARY_DATA ) )
    if (xmloff::token::IsXMLToken(rLocalName, xmloff::token::XML_BINARY_DATA))
    {
        if( !xBase64Stream.is() && pItem->GetGraphicLink().isEmpty() )
        if (!m_xBase64Stream.is())
        {
            const GraphicObject *pGrObj = pItem->GetGraphicObject();
            if( !pGrObj || GraphicType::NONE == pGrObj->GetType() )
            {
                xBase64Stream =
                    GetImport().GetStreamForGraphicObjectURLFromBase64();
                if( xBase64Stream.is() )
                    pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
                                                        rLocalName, xAttrList,
                                                        xBase64Stream );
            }
            m_xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
            if (m_xBase64Stream.is())
                pContext = new XMLBase64ImportContext(GetImport(), nPrefix, rLocalName, xAttrList, m_xBase64Stream);
        }
    }
    if( !pContext )
    if (!pContext)
    {
        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
    }
@@ -140,17 +130,21 @@

void SwXMLBrushItemImportContext::EndElement()
{
    if( xBase64Stream.is() )
    if (m_xBase64Stream.is())
    {
        const OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ) );
        xBase64Stream = nullptr;
        SvXMLImportItemMapper::PutXMLValue( *pItem, sURL, MID_GRAPHIC_LINK, GetImport().GetMM100UnitConverter() );
        m_xGraphic = GetImport().loadGraphicFromBase64(m_xBase64Stream);
        m_xBase64Stream = nullptr;
    }
    if (m_xGraphic.is())
    {
        Graphic aGraphic(m_xGraphic);
        pItem->SetGraphic(aGraphic);
    }

    if( pItem->GetGraphicLink().isEmpty() && !(pItem->GetGraphic()) )
        pItem->SetGraphicPos( GPOS_NONE );
    else if( GPOS_NONE == pItem->GetGraphicPos() )
        pItem->SetGraphicPos( GPOS_TILED );
    if (!(pItem->GetGraphic()))
        pItem->SetGraphicPos(GPOS_NONE);
    else if (GPOS_NONE == pItem->GetGraphicPos())
        pItem->SetGraphicPos(GPOS_TILED);
}

SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
@@ -197,39 +191,42 @@
{
    GetExport().CheckAttrList();

    OUString sURL;
    const SvXMLUnitConverter& rUnitConv = GetExport().GetTwipUnitConverter();
    if( SvXMLExportItemMapper::QueryXMLValue(
            rItem, sURL, MID_GRAPHIC_LINK, rUnitConv ) )
    uno::Reference<graphic::XGraphic> xGraphic;

    const Graphic* pGraphic = rItem.GetGraphic();

    if (pGraphic)
        xGraphic = pGraphic->GetXGraphic();

    if (xGraphic.is())
    {
        OUString sValue = GetExport().AddEmbeddedGraphicObject( sURL );
        if( !sValue.isEmpty() )
        OUString sMimeType;
        OUString sValue = GetExport().AddEmbeddedXGraphic(xGraphic, sMimeType);
        if (!sValue.isEmpty())
        {
            GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sValue );
            GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
            GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
        }

        if( SvXMLExportItemMapper::QueryXMLValue(
                rItem, sValue, MID_GRAPHIC_POSITION, rUnitConv ) )
        const SvXMLUnitConverter& rUnitConv = GetExport().GetTwipUnitConverter();
        if (SvXMLExportItemMapper::QueryXMLValue(rItem, sValue, MID_GRAPHIC_POSITION, rUnitConv))
            GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION, sValue );

        if( SvXMLExportItemMapper::QueryXMLValue(
                rItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv ) )
        if (SvXMLExportItemMapper::QueryXMLValue(rItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv))
            GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REPEAT, sValue );

        if( SvXMLExportItemMapper::QueryXMLValue(
                rItem, sValue, MID_GRAPHIC_FILTER, rUnitConv ) )
        if (SvXMLExportItemMapper::QueryXMLValue(rItem, sValue, MID_GRAPHIC_FILTER, rUnitConv))
            GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_FILTER_NAME, sValue );
    }

    {
        SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, XML_BACKGROUND_IMAGE,
                                  true, true );
        if( !sURL.isEmpty() )
        if (xGraphic.is())
        {
            // optional office:binary-data
            GetExport().AddEmbeddedGraphicObjectAsBase64( sURL );
            GetExport().AddEmbeddedXGraphicAsBase64(xGraphic);
        }
    }
}
diff --git a/sw/source/filter/xml/xmlbrshi.hxx b/sw/source/filter/xml/xmlbrshi.hxx
index 75d5da2..3e07e42 100644
--- a/sw/source/filter/xml/xmlbrshi.hxx
+++ b/sw/source/filter/xml/xmlbrshi.hxx
@@ -22,6 +22,7 @@

#include <memory>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>

#include <xmloff/xmlictxt.hxx>

@@ -36,8 +37,10 @@
class SwXMLBrushItemImportContext : public SvXMLImportContext
{
private:
    css::uno::Reference < css::io::XOutputStream > xBase64Stream;
    std::unique_ptr<SvxBrushItem>                  pItem;
    css::uno::Reference<css::io::XOutputStream> m_xBase64Stream;
    css::uno::Reference<css::graphic::XGraphic> m_xGraphic;

    std::unique_ptr<SvxBrushItem> pItem;

    void ProcessAttrs(
               const css::uno::Reference<css::xml::sax::XAttributeList > & xAttrList,
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index c423443..69f982f 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -902,18 +902,6 @@
                    bOk = true;
                    break;

                case MID_GRAPHIC_LINK:
                    if (rBrush.GetGraphicPos() != GPOS_NONE)
                    {
                        uno::Any aAny;
                        rBrush.QueryValue( aAny, MID_GRAPHIC_URL );
                        OUString sTmp;
                        aAny >>= sTmp;
                        aOut.append( sTmp );
                        bOk = true;
                    }
                    break;

                case MID_GRAPHIC_POSITION:
                    switch (rBrush.GetGraphicPos())
                    {
diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx
index 6806ae9..13f8591 100644
--- a/sw/source/filter/xml/xmlimpit.cxx
+++ b/sw/source/filter/xml/xmlimpit.cxx
@@ -661,17 +661,6 @@
                    }
                    break;

                case MID_GRAPHIC_LINK:
                {
                    SvxGraphicPosition eOldGraphicPos = rBrush.GetGraphicPos();
                    rBrush.PutValue( Any(rValue), MID_GRAPHIC_URL );
                    if( GPOS_NONE == eOldGraphicPos &&
                        GPOS_NONE != rBrush.GetGraphicPos() )
                        rBrush.SetGraphicPos( GPOS_TILED );
                    bOk = true;
                }
                break;

                case MID_GRAPHIC_REPEAT:
                {
                    SvxGraphicPosition eGraphicPos = rBrush.GetGraphicPos();
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index b406c44..71e839e 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/PositionAndSpaceMode.hpp>
#include <com/sun/star/text/XChapterNumberingSupplier.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>

#include <osl/diagnose.h>
#include <rtl/ustring.hxx>
@@ -241,7 +242,7 @@
    sal_Int16 nNumberFormat = ConversionHelper::ConvertNumberingType(m_nNFC);
    if( m_nNFC >= 0)
    {
        if (!m_sGraphicURL.isEmpty() || m_sGraphicBitmap.is())
        if (m_sGraphicBitmap.is())
            nNumberFormat = style::NumberingType::BITMAP;
        else if (m_sBulletChar.isEmpty() && nNumberFormat != style::NumberingType::CHAR_SPECIAL)
            // w:lvlText is empty, that means no numbering in Word.
@@ -268,8 +269,6 @@
                aNumberingProperties.push_back(lcl_makePropVal<sal_Unicode>(PROP_BULLET_CHAR, 0));
            }
        }
        if (!m_sGraphicURL.isEmpty())
            aNumberingProperties.push_back(lcl_makePropVal(PROP_GRAPHIC_URL, m_sGraphicURL));
        if (m_sGraphicBitmap.is())
        {
            aNumberingProperties.push_back(lcl_makePropVal(PROP_GRAPHIC_BITMAP, m_sGraphicBitmap));
@@ -879,17 +878,21 @@
                    uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
                    try
                    {
                        uno::Any aAny = xPropertySet->getPropertyValue("GraphicURL");
                        if (aAny.has<OUString>() && pCurrentLevel)
                            pCurrentLevel->SetGraphicURL(aAny.get<OUString>());
                    } catch(const beans::UnknownPropertyException&)
                        uno::Any aAny = xPropertySet->getPropertyValue("GraphicBitmap");
                        if (aAny.has<uno::Reference<graphic::XGraphic>>() && pCurrentLevel)
                            pCurrentLevel->SetGraphicBitmap(aAny.get<uno::Reference<graphic::XGraphic>>());
                    }
                    catch (const beans::UnknownPropertyException&)
                    {}

                    try
                    {
                        uno::Reference< graphic::XGraphic > gr;
                        xPropertySet->getPropertyValue("Bitmap") >>= gr;
                        pCurrentLevel->SetGraphicBitmap( gr );
                    } catch(const beans::UnknownPropertyException&)
                        uno::Any aAny = xPropertySet->getPropertyValue("Bitmap");
                        if (aAny.has<uno::Reference<graphic::XGraphic>>() && pCurrentLevel)
                            pCurrentLevel->SetGraphicBitmap(aAny.get<uno::Reference<graphic::XGraphic>>());

                    }
                    catch (const beans::UnknownPropertyException&)
                    {}

                    // Respect only the aspect ratio of the picture, not its size.
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index 339e6d4..f93269b 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -46,7 +46,6 @@
    sal_Int32                                     m_nJC;             //LN_JC
    sal_Int16                                     m_nXChFollow;      //LN_IXCHFOLLOW
    OUString                               m_sBulletChar;
    OUString                               m_sGraphicURL;
    css::awt::Size                         m_aGraphicSize;
    css::uno::Reference<css::graphic::XGraphic> m_sGraphicBitmap;
    sal_Int32                                     m_nTabstop;
@@ -70,7 +69,6 @@
    // Setters for the import
    void SetValue( Id nId, sal_Int32 nValue );
    void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
    void SetGraphicURL( const OUString& sValue ) { m_sGraphicURL = sValue; };
    void SetGraphicSize( const css::awt::Size& aValue ) { m_aGraphicSize = aValue; };

    void SetGraphicBitmap(css::uno::Reference<css::graphic::XGraphic> const& sValue)
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 6035b61..592063a 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -291,7 +291,6 @@
        case PROP_SHADOW_FORMAT: sName = "ShadowFormat"; break;
        case PROP_RELATIVE_WIDTH: sName = "RelativeWidth"; break;
        case PROP_IS_WIDTH_RELATIVE: sName = "IsWidthRelative"; break;
        case PROP_GRAPHIC_URL: sName = "GraphicURL"; break;
        case PROP_GRAPHIC_BITMAP: sName = "GraphicBitmap"; break;
        case PROP_GRAPHIC_SIZE: sName = "GraphicSize"; break;
        case PROP_CHAR_SHADING_VALUE: sName = "CharShadingValue"; break;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index f69b653..a3465fe 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -288,7 +288,6 @@
        ,PROP_SHADOW_FORMAT
        ,PROP_RELATIVE_WIDTH
        ,PROP_IS_WIDTH_RELATIVE
        ,PROP_GRAPHIC_URL
        ,PROP_GRAPHIC_BITMAP
        ,PROP_GRAPHIC_SIZE
        ,PROP_CHAR_SHADING_VALUE
diff --git a/xmloff/inc/XMLBackgroundImageContext.hxx b/xmloff/inc/XMLBackgroundImageContext.hxx
index e965935..8080f3f 100644
--- a/xmloff/inc/XMLBackgroundImageContext.hxx
+++ b/xmloff/inc/XMLBackgroundImageContext.hxx
@@ -35,11 +35,11 @@
    XMLPropertyState aTransparencyProp;

    css::style::GraphicLocation ePos;
    OUString sURL;
    OUString m_sURL;
    OUString sFilter;
    sal_Int8 nTransparency;

    css::uno::Reference < css::io::XOutputStream > xBase64Stream;
    css::uno::Reference < css::io::XOutputStream > m_xBase64Stream;

private:
    void ProcessAttrs(
diff --git a/xmloff/source/style/PageMasterStyleMap.cxx b/xmloff/source/style/PageMasterStyleMap.cxx
index 7b11abb..50b90fe 100644
--- a/xmloff/source/style/PageMasterStyleMap.cxx
+++ b/xmloff/source/style/PageMasterStyleMap.cxx
@@ -75,7 +75,7 @@
    PLMAP( "BackTransparent",            XML_NAMESPACE_FO,        XML_BACKGROUND_COLOR,            XML_TYPE_ISTRANSPARENT | MID_FLAG_MERGE_ATTRIBUTE,        0 ),
    PLMAP( "BackGraphicLocation",        XML_NAMESPACE_STYLE,    XML_POSITION,                    XML_TYPE_BUILDIN_CMP_ONLY | MID_FLAG_SPECIAL_ITEM,        CTF_PM_GRAPHICPOSITION ),
    PLMAP( "BackGraphicFilter",        XML_NAMESPACE_STYLE,    XML_FILTER_NAME,                XML_TYPE_STRING | MID_FLAG_SPECIAL_ITEM,                CTF_PM_GRAPHICFILTER ),
    PLMAP( "BackGraphicURL",            XML_NAMESPACE_STYLE,    XML_BACKGROUND_IMAGE,            XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM,                CTF_PM_GRAPHICURL ),
    PLMAP( "BackGraphic",            XML_NAMESPACE_STYLE,    XML_BACKGROUND_IMAGE,            XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM,                CTF_PM_GRAPHICURL ),
    PLMAP( "PrintAnnotations",        XML_NAMESPACE_STYLE,    XML_PRINT,                        XML_PM_TYPE_PRINTANNOTATIONS | MID_FLAG_MULTI_PROPERTY,                            CTF_PM_PRINT_ANNOTATIONS ),
    PLMAP( "PrintCharts",                XML_NAMESPACE_STYLE,    XML_PRINT,                        XML_PM_TYPE_PRINTCHARTS | MID_FLAG_MULTI_PROPERTY | MID_FLAG_MERGE_ATTRIBUTE,    CTF_PM_PRINT_CHARTS ),
    PLMAP( "PrintDrawing",            XML_NAMESPACE_STYLE,    XML_PRINT,                        XML_PM_TYPE_PRINTDRAWING | MID_FLAG_MULTI_PROPERTY | MID_FLAG_MERGE_ATTRIBUTE,    CTF_PM_PRINT_DRAWING ),
@@ -184,7 +184,7 @@
    HFMAP( "HeaderBackTransparent",        XML_NAMESPACE_FO,        XML_BACKGROUND_COLOR,            XML_TYPE_ISTRANSPARENT | MID_FLAG_MERGE_ATTRIBUTE,        CTF_PM_HEADERFLAG ),
    HFMAP( "HeaderBackGraphicLocation",    XML_NAMESPACE_STYLE,    XML_POSITION,                    XML_TYPE_BUILDIN_CMP_ONLY | MID_FLAG_SPECIAL_ITEM,        CTF_PM_HEADERGRAPHICPOSITION ),
    HFMAP( "HeaderBackGraphicFilter",        XML_NAMESPACE_STYLE,    XML_FILTER_NAME,                XML_TYPE_STRING | MID_FLAG_SPECIAL_ITEM,                CTF_PM_HEADERGRAPHICFILTER ),
    HFMAP( "HeaderBackGraphicURL",        XML_NAMESPACE_STYLE,    XML_BACKGROUND_IMAGE,            XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM,                CTF_PM_HEADERGRAPHICURL ),
    HFMAP( "HeaderBackGraphic",        XML_NAMESPACE_STYLE,    XML_BACKGROUND_IMAGE,            XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM,                CTF_PM_HEADERGRAPHICURL ),
    HFMAP( "HeaderDynamicSpacing",        XML_NAMESPACE_STYLE,    XML_DYNAMIC_SPACING,            XML_TYPE_BOOL,          CTF_PM_HEADERFLAG ),

    //Index 121: Header DrawingLayer FillAttributes
@@ -240,7 +240,7 @@
    HFMAP( "FooterBackTransparent",        XML_NAMESPACE_FO,        XML_BACKGROUND_COLOR,            XML_TYPE_ISTRANSPARENT | MID_FLAG_MERGE_ATTRIBUTE,        CTF_PM_FOOTERFLAG ),
    HFMAP( "FooterBackGraphicLocation",    XML_NAMESPACE_STYLE,    XML_POSITION,                    XML_TYPE_BUILDIN_CMP_ONLY | MID_FLAG_SPECIAL_ITEM,        CTF_PM_FOOTERGRAPHICPOSITION ),
    HFMAP( "FooterBackGraphicFilter",     XML_NAMESPACE_STYLE,    XML_FILTER_NAME,                XML_TYPE_STRING | MID_FLAG_SPECIAL_ITEM,                CTF_PM_FOOTERGRAPHICFILTER ),
    HFMAP( "FooterBackGraphicURL",        XML_NAMESPACE_STYLE,    XML_BACKGROUND_IMAGE,            XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM,                CTF_PM_FOOTERGRAPHICURL ),
    HFMAP( "FooterBackGraphic",           XML_NAMESPACE_STYLE,    XML_BACKGROUND_IMAGE,            XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM,                CTF_PM_FOOTERGRAPHICURL ),
    HFMAP( "FooterDynamicSpacing",        XML_NAMESPACE_STYLE,    XML_DYNAMIC_SPACING,           XML_TYPE_BOOL,          CTF_PM_FOOTERFLAG ),

    //Index 170: Footer DrawingLayer FillAttributes
diff --git a/xmloff/source/style/XMLBackgroundImageContext.cxx b/xmloff/source/style/XMLBackgroundImageContext.cxx
index 28c421f..39d9b16 100644
--- a/xmloff/source/style/XMLBackgroundImageContext.cxx
+++ b/xmloff/source/style/XMLBackgroundImageContext.cxx
@@ -185,7 +185,7 @@
        switch( aTokenMap.Get( nPrefix, aLocalName ) )
        {
        case XML_TOK_BGIMG_HREF:
            sURL = rValue;
            m_sURL = rValue;
            if( GraphicLocation_NONE == ePos )
                ePos = GraphicLocation_TILED;
            break;
@@ -353,13 +353,13 @@
        xmloff::token::IsXMLToken( rLocalName,
                                        xmloff::token::XML_BINARY_DATA ) )
    {
        if( sURL.isEmpty() && !xBase64Stream.is() )
        if( m_sURL.isEmpty() && !m_xBase64Stream.is() )
        {
            xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
            if( xBase64Stream.is() )
            m_xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
            if( m_xBase64Stream.is() )
                pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
                                                    rLocalName, xAttrList,
                                                    xBase64Stream );
                                                    m_xBase64Stream );
        }
    }
    if( !pContext )
@@ -372,23 +372,24 @@

void XMLBackgroundImageContext::EndElement()
{
    if( !sURL.isEmpty() )
    uno::Reference<graphic::XGraphic> xGraphic;
    if (!m_sURL.isEmpty())
    {
        sURL = GetImport().ResolveGraphicObjectURL( sURL, false );
        xGraphic = GetImport().loadGraphicByURL(m_sURL);
    }
    else if( xBase64Stream.is() )
    else if (m_xBase64Stream.is())
    {
        sURL = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream );
        xBase64Stream = nullptr;
        xGraphic = GetImport().loadGraphicFromBase64(m_xBase64Stream);
        m_xBase64Stream = nullptr;
    }

    if( sURL.isEmpty() )
    if (!xGraphic.is())
        ePos = GraphicLocation_NONE;
    else if( GraphicLocation_NONE == ePos )
    else if (GraphicLocation_NONE == ePos)
        ePos = GraphicLocation_TILED;

    if (!sURL.isEmpty())
        aProp.maValue <<= sURL;
    if (xGraphic.is())
        aProp.maValue <<= xGraphic;
    aPosProp.maValue <<= ePos;
    aFilterProp.maValue <<= sFilter;
    aTransparencyProp.maValue <<= nTransparency;
diff --git a/xmloff/source/style/XMLBackgroundImageExport.cxx b/xmloff/source/style/XMLBackgroundImageExport.cxx
index 8e74461..abedea9 100644
--- a/xmloff/source/style/XMLBackgroundImageExport.cxx
+++ b/xmloff/source/style/XMLBackgroundImageExport.cxx
@@ -43,7 +43,7 @@
{
}

void XMLBackgroundImageExport::exportXML( const Any& rURL,
void XMLBackgroundImageExport::exportXML( const Any& rGraphicAny,
            const Any *pPos,
            const Any *pFilter,
            const Any *pTransparency,
@@ -54,18 +54,20 @@
    if( !(pPos && ((*pPos) >>= ePos)) )
        ePos = GraphicLocation_AREA;

    OUString sURL;
    rURL >>= sURL;
    if( !sURL.isEmpty() && GraphicLocation_NONE != ePos )
    uno::Reference<graphic::XGraphic> xGraphic;
    if (rGraphicAny.has<uno::Reference<graphic::XGraphic>>())
        xGraphic = rGraphicAny.get<uno::Reference<graphic::XGraphic>>();

    if (xGraphic.is() && GraphicLocation_NONE != ePos)
    {
        OUString sTempURL( GetExport().AddEmbeddedGraphicObject( sURL ) );
        if( !sTempURL.isEmpty() )
        OUString sUsedMimeType;
        OUString sInternalURL(GetExport().AddEmbeddedXGraphic(xGraphic, sUsedMimeType));

        if (!sInternalURL.isEmpty())
        {
            GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sTempURL );
            GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE,
                                      XML_SIMPLE );
            GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE,
                                      XML_ONLOAD );
            GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sInternalURL);
            GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
            GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD);
        }

        OUStringBuffer aOut;
@@ -154,11 +156,11 @@
    }

    {
        SvXMLElementExport aElem( GetExport(), nPrefix, rLocalName, true, true );
        if( !sURL.isEmpty() && GraphicLocation_NONE != ePos )
        SvXMLElementExport aElem(GetExport(), nPrefix, rLocalName, true, true);
        if (xGraphic.is() && GraphicLocation_NONE != ePos)
        {
            // optional office:binary-data
            GetExport().AddEmbeddedGraphicObjectAsBase64( sURL );
            GetExport().AddEmbeddedXGraphicAsBase64(xGraphic);
        }
    }
}
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index a3d4ca8..d48f940 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.cxx
@@ -77,7 +77,7 @@
            aSet.insert("BackColorRGB");
            aSet.insert("BackTransparent");
            aSet.insert("BackColorTransparency");
            aSet.insert("BackGraphicURL");
            aSet.insert("BackGraphic");
            aSet.insert("BackGraphicFilter");
            aSet.insert("BackGraphicLocation");
            aSet.insert("BackGraphicTransparency");
@@ -93,7 +93,7 @@
            aSet.insert("HeaderBackColorRGB");
            aSet.insert("HeaderBackTransparent");
            aSet.insert("HeaderBackColorTransparency");
            aSet.insert("HeaderBackGraphicURL");
            aSet.insert("HeaderBackGraphic");
            aSet.insert("HeaderBackGraphicFilter");
            aSet.insert("HeaderBackGraphicLocation");
            aSet.insert("HeaderBackGraphicTransparency");
@@ -109,7 +109,7 @@
            aSet.insert("FooterBackColorRGB");
            aSet.insert("FooterBackTransparent");
            aSet.insert("FooterBackColorTransparency");
            aSet.insert("FooterBackGraphicURL");
            aSet.insert("FooterBackGraphic");
            aSet.insert("FooterBackGraphicFilter");
            aSet.insert("FooterBackGraphicLocation");
            aSet.insert("FooterBackGraphicTransparency");
@@ -128,7 +128,7 @@
            aSet.insert("ParaBackTransparent");
            aSet.insert("ParaBackGraphicLocation");
            aSet.insert("ParaBackGraphicFilter");
            aSet.insert("ParaBackGraphicURL");
            aSet.insert("ParaBackGraphic");

            // These are not used in aXMLParaPropMap definition, thus not needed here
            // aSet.insert("ParaBackColorTransparency");
diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx
index 63e5b89d..e396546 100644
--- a/xmloff/source/style/xmlnume.cxx
+++ b/xmloff/source/style/xmlnume.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XIndexReplace.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
@@ -37,7 +38,6 @@

#include <rtl/ustrbuf.hxx>


#include <sax/tools/converter.hxx>

#include <xmloff/nmspmap.hxx>
@@ -95,8 +95,8 @@
    FontPitch eBulletFontPitch = PITCH_DONTKNOW;
    rtl_TextEncoding eBulletFontEncoding = RTL_TEXTENCODING_DONTKNOW;

    OUString sImageURL;
    uno::Reference< css::awt::XBitmap >  xBitmap;
    uno::Reference<graphic::XGraphic> xGraphic;

    sal_Int32 nImageWidth = 0, nImageHeight = 0;
    sal_Int16 eImageVertOrient = VertOrientation::LINE_CENTER;

@@ -155,13 +155,11 @@
                eBulletFontEncoding = static_cast<rtl_TextEncoding>(rFDesc.CharSet);
            }
        }
        else if( rProp.Name == "GraphicURL" )
        {
            rProp.Value >>= sImageURL;
        }
        else if( rProp.Name == "GraphicBitmap" )
        {
            uno::Reference<awt::XBitmap> xBitmap;
            rProp.Value >>= xBitmap;
            xGraphic.set(xBitmap, uno::UNO_QUERY);
        }
        else if( rProp.Name == "BulletColor" )
        {
@@ -299,14 +297,13 @@

        eElem = XML_LIST_LEVEL_STYLE_IMAGE;


        if( !sImageURL.isEmpty() )
        if (xGraphic.is())
        {
            OUString sURL( GetExport().AddEmbeddedGraphicObject( sImageURL ) );
            if( !sURL.isEmpty() )
            OUString sUsedMimeType;
            OUString sInternalURL = GetExport().AddEmbeddedXGraphic(xGraphic, sUsedMimeType);
            if (!sInternalURL.isEmpty())
            {
                GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );

                GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sInternalURL);
                GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
                GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
                GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
@@ -314,8 +311,7 @@
        }
        else
        {
            SAL_WARN_IF( xBitmap.is(), "xmloff",
                        "embedded images are not supported by now" );
            SAL_WARN_IF(xGraphic.is(), "xmloff", "embedded images are not supported by now");
        }
    }
    else
@@ -602,10 +598,10 @@
            SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE,
                                      XML_TEXT_PROPERTIES, true, true );
        }
        if( NumberingType::BITMAP == eType && !sImageURL.isEmpty() )
        if (xGraphic.is() && NumberingType::BITMAP == eType)
        {
            // optional office:binary-data
            GetExport().AddEmbeddedGraphicObjectAsBase64( sImageURL );
            GetExport().AddEmbeddedXGraphicAsBase64(xGraphic);
        }
    }
}
diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx
index 993b100..482dd4f 100644
--- a/xmloff/source/text/txtprhdl.cxx
+++ b/xmloff/source/text/txtprhdl.cxx
@@ -37,6 +37,7 @@
#include <com/sun/star/text/RubyPosition.hpp>
#include <com/sun/star/text/FontEmphasis.hpp>
#include <com/sun/star/text/ParagraphVertAlign.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <sax/tools/converter.hxx>
#include <xmloff/xmltypes.hxx>
#include <xmloff/xmluconv.hxx>
@@ -56,6 +57,7 @@
#include <com/sun/star/drawing/RectanglePoint.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <XMLBitmapRepeatOffsetPropertyHandler.hxx>
#include <vcl/graph.hxx>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -1137,6 +1139,38 @@
    return bRet;
}

class XMLGraphicPropertyHandler : public XMLPropertyHandler
{
public:
    XMLGraphicPropertyHandler() {}

    virtual bool importXML(const OUString& , uno::Any& , const SvXMLUnitConverter& ) const override
    {
        SAL_WARN( "xmloff", "drop caps are an element import property" );
        return false;
    }

    virtual bool exportXML(OUString& , const uno::Any& , const SvXMLUnitConverter& ) const override
    {
        SAL_WARN( "xmloff", "drop caps are an element import property" );
        return false;
    }

    virtual bool equals(const css::uno::Any& rAny1, const css::uno::Any& rAny2) const override;
};

bool XMLGraphicPropertyHandler::equals(const Any& rAny1, const Any& rAny2) const
{
    uno::Reference<graphic::XGraphic> xGraphic1;
    uno::Reference<graphic::XGraphic> xGraphic2;
    rAny1 >>= xGraphic1;
    rAny2 >>= xGraphic2;
    Graphic aGraphic1(xGraphic1);
    Graphic aGraphic2(xGraphic2);

    return aGraphic1 == aGraphic2;
}

static const XMLPropertyHandler *GetPropertyHandler
    ( sal_Int32 nType )
{
@@ -1327,7 +1361,9 @@
    case XML_SW_TYPE_BITMAPREPOFFSETY:
        pHdl = new XMLBitmapRepeatOffsetPropertyHandler(XML_SW_TYPE_BITMAPREPOFFSETX == nType);
        break;

    case XML_TYPE_GRAPHIC:
        pHdl = new XMLGraphicPropertyHandler;
        break;
    default:
    {
        OSL_ENSURE(false, "XMLPropertyHandler missing (!)");
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index b6b90c1..ae484f2 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -384,7 +384,7 @@
    MP_E( "ParaBackTransparent",    FO, BACKGROUND_COLOR,       XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
    MP_E( "ParaBackGraphicLocation",    STYLE,  POSITION,   MID_FLAG_SPECIAL_ITEM|XML_TYPE_BUILDIN_CMP_ONLY, CTF_BACKGROUND_POS  ),
    MP_E( "ParaBackGraphicFilter",STYLE,    FILTER_NAME,    MID_FLAG_SPECIAL_ITEM|XML_TYPE_STRING, CTF_BACKGROUND_FILTER ),
    MP_E( "ParaBackGraphicURL", STYLE,  BACKGROUND_IMAGE,   MID_FLAG_ELEMENT_ITEM|XML_TYPE_STRING, CTF_BACKGROUND_URL ),
    MP_E( "ParaBackGraphic", STYLE,  BACKGROUND_IMAGE,   MID_FLAG_ELEMENT_ITEM|XML_TYPE_GRAPHIC, CTF_BACKGROUND_URL ),

    // RES_BOX
    MP_E( "LeftBorder",         STYLE,  BORDER_LINE_WIDTH,        XML_TYPE_BORDER_WIDTH, CTF_ALLBORDERWIDTH ),
@@ -748,7 +748,7 @@
    MG_E( "BackGraphicTransparency", STYLE, BACKGROUND_IMAGE_TRANSPARENCY, MID_FLAG_SPECIAL_ITEM|XML_TYPE_PERCENT8, CTF_BACKGROUND_TRANSPARENCY ),
    MG_E( "BackGraphicLocation",    STYLE,  POSITION,   MID_FLAG_SPECIAL_ITEM|XML_TYPE_BUILDIN_CMP_ONLY, CTF_BACKGROUND_POS  ),
    MG_E( "BackGraphicFilter",STYLE,    FILTER_NAME,    MID_FLAG_SPECIAL_ITEM|XML_TYPE_STRING, CTF_BACKGROUND_FILTER ),
    MG_E( "BackGraphicURL", STYLE,  BACKGROUND_IMAGE,   MID_FLAG_ELEMENT_ITEM|XML_TYPE_STRING, CTF_BACKGROUND_URL ),
    MG_E( "BackGraphic", STYLE,  BACKGROUND_IMAGE,   MID_FLAG_ELEMENT_ITEM|XML_TYPE_GRAPHIC, CTF_BACKGROUND_URL ),

    // fill attributes
    GMAP( "FillStyle",                      XML_NAMESPACE_DRAW, XML_FILL,                   XML_SW_TYPE_FILLSTYLE, 0 ),
@@ -926,7 +926,7 @@
    MS_E( "BackTransparent",    FO, BACKGROUND_COLOR,       XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
    MS_E( "BackGraphicLocation",    STYLE,  POSITION,   MID_FLAG_SPECIAL_ITEM|XML_TYPE_BUILDIN_CMP_ONLY, CTF_BACKGROUND_POS  ),
    MS_E( "BackGraphicFilter",STYLE,    FILTER_NAME,    MID_FLAG_SPECIAL_ITEM|XML_TYPE_STRING, CTF_BACKGROUND_FILTER ),
    MS_E( "BackGraphicURL", STYLE,  BACKGROUND_IMAGE,   MID_FLAG_ELEMENT_ITEM|XML_TYPE_STRING, CTF_BACKGROUND_URL ),
    MS_E( "BackGraphic", STYLE,  BACKGROUND_IMAGE,   MID_FLAG_ELEMENT_ITEM|XML_TYPE_GRAPHIC, CTF_BACKGROUND_URL ),

    // move protect-flag into section element
//  M_E( "IsProtected",         STYLE,  PROTECT,    XML_TYPE_BOOL, 0 ),